{% block sw_product_stream_detail %}
<sw-page class="sw-product-stream-detail">
    {% block sw_product_stream_detail_header %}
    <template #smart-bar-header>
        <h2 v-if="productStream">
            {{ productStream.name }}
        </h2>
        <h2
            v-else
            class="sw-product-stream-detail__empty-title"
        >
            {{ placeholder(productStream, 'name', $tc('sw-product-stream.detail.textHeadline')) }}
        </h2>
    </template>
    {% endblock %}

    {% block sw_product_stream_detail_actions %}
    <template #smart-bar-actions>
        {% block sw_product_stream_detail_actions_abort %}
        <mt-button
            v-tooltip.bottom="tooltipCancel"
            :disabled="isLoading"
            variant="secondary"
            size="default"
            @click="onCancel"
        >
            {{ $tc('global.default.cancel') }}
        </mt-button>
        {% endblock %}

        <sw-button-group
            v-tooltip.bottom="{
                message: $tc('sw-privileges.tooltip.warning'),
                disabled: acl.can('product_stream.editor'),
                showOnDisabledElements: true
            }"
            class="sw-product-stream-detail__save-button-group"
            :split-button="true"
        >
            {% block sw_product_stream_detail_actions_save %}
            <sw-button-process
                v-model:process-success="isSaveSuccessful"
                v-tooltip.bottom="tooltipSave"
                class="sw-product-stream-detail__save-action"
                :is-loading="isLoading"
                :disabled="!acl.can('product_stream.editor')"
                variant="primary"
                @click.prevent="onSave"
            >
                {{ $tc('sw-product-stream.detail.buttonSave') }}
            </sw-button-process>
            {% endblock %}

            {% block sw_product_stream_detail_actions_save_context_menu %}
            <sw-context-button>
                <template #button>
                    <mt-button
                        class="sw-product-stream-detail__button-context-menu"
                        square
                        variant="primary"
                        :disabled="isLoading || !acl.can('product_stream.editor')"
                        size="default"
                    >
                        <mt-icon name="regular-chevron-down-xs" />
                    </mt-button>
                </template>

                {% block sw_product_stream_detail_actions_save_context_menu_actions %}
                {% block sw_product_stream_detail_actions_duplicate %}
                <sw-context-menu-item
                    class="sw-product-stream-detail__save-duplicate-action"
                    :disabled="!acl.can('product_stream.creator') || !acl.can('product_stream.editor')"
                    @click="onDuplicate"
                >
                    {{ $tc('sw-product.detail.buttonSaveDuplicate') }}
                </sw-context-menu-item>
                {% endblock %}
                {% endblock %}
            </sw-context-button>
            {% endblock %}
        </sw-button-group>
    </template>
    {% endblock %}

    {% block sw_product_stream_detail_language_switch %}
    <template #language-switch>
        <sw-language-switch
            :save-changes-function="saveOnLanguageChange"
            :abort-change-function="abortOnLanguageChange"
            :disabled="!productStreamId"
            @on-change="onChangeLanguage"
        />
    </template>
    {% endblock %}

    {% block sw_product_stream_detail_content %}
    <template #content>
        <sw-card-view>
            <template v-if="isLoading || customFieldsLoading">
                <sw-skeleton variant="detail-bold" />
                <sw-skeleton />
            </template>

            <template v-else>

                {% block sw_product_stream_detail_content_language_info %}
                <sw-language-info
                    :entity-description="placeholder(productStream, 'name', $tc('sw-product-stream.detail.textHeadline'))"
                />
                {% endblock %}

                {% block sw_product_stream_detail_basic_info %}
                <mt-card
                    position-identifier="sw-product-stream-detail-basic-info"
                    :large="true"
                    :title="$tc('sw-product-stream.detail.titleCard')"
                >
                    {% block sw_product_basic_form_name_field %}

                    <mt-text-field
                        v-if="productStream"
                        v-model="productStream.name"
                        v-tooltip.bottom="getNoPermissionsTooltip('product_stream.editor')"
                        name="sw-field--productStream-name"
                        :label="$tc('sw-product-stream.detail.labelName')"
                        :validation="nameRequired"
                        :required="isSystemLanguage"
                        :placeholder="placeholder(productStream, 'name', $tc('sw-product-stream.detail.placeholderName'))"
                        :error="productStreamNameError"
                        :disabled="!acl.can('product_stream.editor')"
                    />
                    {% endblock %}

                    {% block sw_product_basic_form_description_field %}
                    <mt-textarea
                        v-if="productStream"
                        v-model="productStream.description"
                        v-tooltip.bottom="getNoPermissionsTooltip('product_stream.editor')"
                        name="sw-field--productStream-description"
                        :label="$tc('sw-product-stream.detail.labelDescription')"
                        :placeholder="placeholder(productStream, 'description', $tc('sw-product-stream.detail.placeholderDescription'))"
                        :disabled="!acl.can('product_stream.editor')"
                    />
                    {% endblock %}
                </mt-card>
                {% endblock %}

                {% block sw_product_stream_detail_filter %}
                <mt-card
                    :large="true"
                    position-identifier="sw-product-stream-detail-filter"
                    class="sw-product-stream-detail__condition_container"
                    :class="{ 'is--disabled': !acl.can('product_stream.editor') }"
                    :title="$tc('sw-product-stream.detail.titleFilter')"
                >
                    {% block sw_product_stream_detail_filter_tree %}
                    <sw-condition-tree
                        v-if="productStream"
                        :initial-conditions="productStreamFilters"
                        :condition-repository="productStreamFiltersRepository"
                        :condition-data-provider-service="productStreamConditionService"
                        child-association-field="queries"
                        association-field="productStreamId"
                        :association-value="productStream.id"
                        :root-condition="null"
                        :disabled="!acl.can('product_stream.editor')"
                        @conditions-changed="updateFilterTree"
                    />
                    {% endblock %}

                    {% block sw_product_stream_detail_filter_preview_button %}
                    <mt-button
                        class="sw-product-stream-detail__open_modal_preview"
                        variant="secondary"
                        @click.prevent="openModalPreview"
                    >
                        {{ $tc('sw-product-stream.detail.buttonOpenPreview') }}
                    </mt-button>
                    {% endblock %}
                </mt-card>
                {% endblock %}

                {% block sw_prouct_stream_detail_preview_modal %}
                <sw-product-stream-modal-preview
                    v-if="showModalPreview"
                    ref="modalPreview"
                    :filters="productStreamFiltersTree"
                    @modal-close="closeModalPreview"
                />
                {% endblock %}

                {% block sw_prouct_stream_detail_custom_field_sets %}
                <mt-card
                    v-if="showCustomFields"
                    position-identifier="sw-product-stream-detail-custom-field-sets"
                    :large="true"
                    :title="$tc('sw-settings-custom-field.general.mainMenuItemGeneral')"
                >
                    <sw-custom-field-set-renderer
                        :entity="productStream"
                        :disabled="!acl.can('product_stream.editor')"
                        :sets="customFieldSets"
                    />
                </mt-card>
                {% endblock %}
            </template>
        </sw-card-view>
    </template>
    {% endblock %}
</sw-page>
{% endblock %}
